package com.ruoyi.aslife.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aslife.domain.Comment;
import com.ruoyi.aslife.service.ICommentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;


@RestController
@RequestMapping("/api")
public class CommentController2  extends BaseController {

    @Autowired
    private ICommentService commentService;

    @GetMapping("/comment/list")
    public TableDataInfo list(Comment comment)
    {
        startPage();
        List<Comment> list = commentService.selectCommentList(comment);
        return getDataTable(list);
    }

    /**
     * 获取评论信息管理详细信息
     */
    @GetMapping(value = "/comment/{cid}")
    public AjaxResult getInfo(@PathVariable("cid") Long cid)
    {
        return success(commentService.selectCommentByCid(cid));
    }

    /**
     * 查询一级评论
     * @param pageNo
     * @param pageSize
     * @param aid
     * @return
     */
    @GetMapping(value = "/commentFirstByGoods/{aid}")
    public PageInfo<Comment> selectByPage(
            @RequestParam(required = false,value = "page",defaultValue = "1")Integer pageNo,
            @RequestParam(required = false,value = "pageSize",defaultValue = "5")Integer pageSize,
            @PathVariable("aid") Integer aid

    ){
        PageInfo<Comment> comment = PageInfo.of(commentService.selectCommentFirstByGoods(pageNo, pageSize, aid));
        return comment;
    }

}
